<!-- 
 -->
<template>
  <div class="listPage">
    <div>
      <mListModuleTitle
        :titleText="this.listTitleObj.titleText"
        :showIcon="this.listTitleObj.showIcon"
      />
      <el-table :data="tableData" style="width: 100%" v-loading="loading">
        <el-table-column prop="username" label="用户名" width="180">
        </el-table-column>
        <el-table-column prop="mobile" label="手机号" width="180">
        </el-table-column>
        <el-table-column prop="create_time" label="创建时间"> </el-table-column>
        <el-table-column prop="status" label="状态"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <span
              class="user_operation_btn user_btn_edit"
              @click="handleEdit(scope.row)"
            ></span>
            <span
              class="user_operation_btn user_btn_delete"
              @click="handleDelete(scope.$index, scope.row)"
            ></span>

            <!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>

      <div class="mPaginationBox">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="total"
          :hide-on-single-page="true"
          @current-change="listCurrentChange"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: true,
      currentPage: 1,
      total: 0,
      limit: 10,
      listTitleObj: {
        titleText: "用户列表",
        showIcon: true,
      },
      tableData: [],
    };
  },
  methods: {
    handleEdit(item) {
      console.log(item);
      let routeName = this.$route.path;
      this.$router.push({
        path: `/user/userList/edit/${item.id}`,
      });
    },
    listCurrentChange(val) {
      this.loading = true;
      this.currentPage = val;
      this.getData();
    },
    getData() {
      this.$api.userApi
        .getUserLIst({
          offset: (this.currentPage - 1) * this.limit,
          limit: 10,
        })
        .then((res) => {
          this.tableData = res.data.data;
          this.loading = false;
        });
    },
  },
  mounted() {
    this.getData();
  },
};
</script>
<style  scoped>
</style>